package link;

import array.ListNode;

public class RemoveDuplicatesFromSortedListii82 {
    public ListNode deleteDuplicates(ListNode head) {
        if (head == null) {
            return head;
        }
        ListNode idle = new ListNode();
        idle.next = head;
        ListNode result = idle;
        while (idle.next != null && idle.next.next != null) {
            if (idle.next.val == idle.next.next.val) {
                int var = idle.next.val;
                ListNode temp = idle.next;
                while (temp.next != null && temp.next.val == var) {
                    temp = temp.next;
                }
                idle.next = temp.next;
            } else {
                idle = idle.next;
            }

        }
        return result.next;
    }
}
